package com.wjl.shop.service.impl;

import com.wjl.shop.entity.DealerAddress;
import com.wjl.shop.dao.DealerAddressDao;
import com.wjl.shop.service.DealerAddressService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 经销商------地址关系表(DealerAddress)表服务实现类
 *
 * @author makejava
 * @since 2021-10-06 14:43:19
 */
@Service("dealerAddressService")
public class DealerAddressServiceImpl implements DealerAddressService {
    @Resource
    private DealerAddressDao dealerAddressDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public DealerAddress queryById(Integer id) {
        return this.dealerAddressDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<DealerAddress> queryAllByLimit(int offset, int limit) {
        return this.dealerAddressDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param dealerAddress 实例对象
     * @return 实例对象
     */
    @Override
    public DealerAddress insert(DealerAddress dealerAddress) {
        this.dealerAddressDao.insert(dealerAddress);
        return dealerAddress;
    }

    /**
     * 修改数据
     *
     * @param dealerAddress 实例对象
     * @return 实例对象
     */
    @Override
    public DealerAddress update(DealerAddress dealerAddress) {
        this.dealerAddressDao.update(dealerAddress);
        return this.queryById(dealerAddress.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.dealerAddressDao.deleteById(id) > 0;
    }
}
